package com.jsoft.jsofted.sys.mapper;

import com.diboot.core.mapper.BaseCrudMapper;
import com.jsoft.jsofted.sys.entity.UserEntity;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

@Repository
public interface UserMapper extends BaseCrudMapper<UserEntity> {

    @Select("SELECT u.*, o.name as orgName, o.full_name as orgFullName FROM sys_user u JOIN sys_org o ON u.org_id = o.id WHERE (username = #{username} OR tel = #{username}) AND password = #{password}")
    UserEntity getForLogin(String username, String password);

    @Select("SELECT u.*, o.name as orgName, o.full_name as orgFullName FROM sys_user u JOIN sys_org o ON u.org_id = o.id WHERE username = #{username}")
    UserEntity getByUsername(String username);
}
